const a = '1234567876543265432345'
const b = '2345678876542345678898'

function add(n, m) {
  // 确保参数是字符串
  const strn = n.toString()
  console.log(strn);
  const strm = m.toString()
  console.log(strm);
  // 获取两个字符串的长度
  const len = Math.max(strn.length, strm.length)
  
  // 对齐两个字符串的长度，用前导零补齐
  const paddedN = strn.padStart(len, '0')
  const paddedM = strm.padStart(len, '0')
  
  let result = ''
  let carry = 0
  
  // 从右到左逐位相加
  for (let i = len - 1; i >= 0; i--) {
    const sum = Number(paddedN[i]) + Number(paddedM[i]) + carry
    result = (sum % 10) + result
    carry = Math.floor(sum / 10)
  }
  
  // 如果最后还有进位，添加到结果前面
  if (carry > 0) {
    result = carry + result
  }
  
  return +result
}
add(a,b)